


options ls=200 nofmterr;


libname zip  '/data/cahps/data_supp/census2000';
libname area '/data/cahps/data_supp/arf';
libname new  '/data/Medicare_P01_2009/data/HEDIS/sasdata';


data zip; set zip.national_zcta_extract;

    keep  zip5             fips_st             fips_cty
          a65_eduatt_hs    a65_eduatt_somecol  a65_eduatt_college
          inchh_mdn_65_74  inchh_mdn_75        a65_povstat_below;

    proc sort; by fips_st fips_cty;

data arf0; set area.arf2007;

     rename 
        f00011 = fips_st
        f00012 = fips_cty
        f0002003 = beale_code
        f00008 = state_name 
        f00023 = fedregion  ;
   run;

    
data arf; set arf0;

     keep fips_st fips_cty beale_code state_name fedregion;

     proc sort; by fips_st fips_cty;

data new.zipinfo; merge zip(in=ok) arf; by fips_st fips_cty;

     if ok;

     length beale_name $ 50 ; 

        if beale_code='01' then beale_name = '1-Metro: 1,000,000 +' ;
        if beale_code='02' then beale_name = '2-Metro: 250,000 to 1,000,000';
        if beale_code='03' then beale_name = '3-Metro: Under 250,000';
        if beale_code='04' then beale_name = '4-Urban pop 20,000 +, adjacent metro area';
        if beale_code='05' then beale_name = '5-Urban pop 20,000 +, not adjacent metro area';
        if beale_code='06' then beale_name = '6-Urban pop 2,500-19,999, adjacent metro area';
        if beale_code='07' then beale_name = '7-Urban pop 2,500-19,999, not adjacent metro area';
        if beale_code='08' then beale_name = '8-Rural/under 2,500 pop, adjacent metro area';
        if beale_code='09' then beale_name = '9-Rural/under 2,500 pop, not adjacent metro area';
        if beale_code='99' then beale_name = '99-Missing Value';

    if beale_code in ('06','07','08','09') then rural=1; else rural=0; 
    if beale_code in ('99') then rural=.;

     proc contents varnum;
          title 'Content Listing of zipinfo.sas7bdat';
  

endsas;



